package logic

import (
	"context"
	"github.com/zeromicro/go-zero/core/logx"
	"homepage_srv/homepage"
	"homepage_srv/internal/dao"
	"homepage_srv/internal/svc"
	"smart-health-platforms/pkg"
)

type GoodCreateLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewGoodCreateLogic(ctx context.Context, svcCtx *svc.ServiceContext) *GoodCreateLogic {
	return &GoodCreateLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 商品添加
func (l *GoodCreateLogic) GoodCreate(in *homepage.GoodCreateRequest) (*homepage.GoodCreateResponse, error) {
	//添加商品入库
	good, err := dao.GoodCreate(in)
	if err != nil {
		pkg.Warn("商品添加失败")
		return nil, err
	}
	pkg.Warn("商品添加成功")
	return &homepage.GoodCreateResponse{
		Id: uint64(good),
	}, nil
}
